﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
    <link href="../CSS/style3.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script type="text/javascript">
        var id = 1;
        function baocun() {
            var p = {
                ChanID: window.dialogArguments.id,
                PlanContent: $("#t1").val(),
            };
            //设置action
            p.action = "update";
            //发起更新请求
            $.post("SaleOpen.ashx", p, function (r) {
                if (r == "0") {
                    alert("保存失败");
                } else {
                    reloadList();
                    $('.planTR').toggle();
                    
                }
            });
        }
        function baocun1() {
            var p = {
                PlanID:id,
                ChanID: window.dialogArguments.id,
                PlanResult: $("#t2").val()
            };
            //设置action
            p.action = "update1";
            //发起更新请求
            $.post("SaleOpen.ashx", p, function (r) {
                if (r == "0") {
                    alert("保存失败");
                } else {
                    reloadList();
                    $('.resultTR').toggle();
                }
            });
        }
        function chengg() {
            if(!confirm("确定要开发成功吗？"))return;
            var p = {
                ChanID: window.dialogArguments.id
            };
            //设置action
            p.action = "update2";
            //发起更新请求
            $.post("SaleOpen.ashx", p, function (r) {
                if (r == "0") {
                    alert("保存失败");
                } else {
                    window.returnValue = true;
                    window.close();
                }
            });
        }
        function shibai() {
            var p = {
                ChanID: window.dialogArguments.id,
                ChanError: $("#t3").val()
            };
            //设置action
            p.action = "update3";
            //发起更新请求
            $.post("SaleOpen.ashx", p, function (r) {
                if (r == "0") {
                    alert("保存失败");
                } else {
                    window.returnValue = true;
                    window.close();
                }
            });
        }
        function aa(id1) {
            $('.resultTR').toggle();
            id = id1;
        }
        function date2str(date) {
            //null判断
            if (date == null) return "";
            //去掉左右的斜杠
            date = date.replace(/\//g, "");
            //将其转为一个日期对象
            eval("var d = new " + date + ";");
            //返回最终结果
            return d.getFullYear() + "年" + (d.getMonth() + 1) + "月" + d.getDate()+"日";
        }
        $(function () {
            //查询出全部显示，并显示到<table>标签上
            reloadList();
        });

        //查询出全部显示，并显示到<table>标签上
        function reloadList() {
            var id = window.dialogArguments.id;
            $.get("SaleOpen.ashx", { action: "find", id: id }, function (p) {
                //将服务器返回的结果，转为js的数组
                var arr = JSON.parse(p);
                //找到tb1这个表格，转为dom对象
                var tb1 = $("#tb1").get(0);
                //删除原来的数据
                $(tb1).find("tr:gt(5)").remove();
                //加载每一行
                for (var i = 0; i < arr.length; i++) {
                    //添加一行
                    var tr = tb1.insertRow(-1);
                    tr.insertCell(-1).innerHTML = "计划：" + date2str(arr[i].PlanDate);
                    tr.insertCell(-1).innerHTML = "执行：" + date2str(arr[i].PlanResultDate);
                    var tr = tb1.insertRow(-1);
                    tr.insertCell(-1).innerHTML = arr[i].PlanContent;
                    tr.insertCell(-1).innerHTML = arr[i].PlanResult || '<input type="button" value="输入执行结果" onclick="aa(' + arr[i].PlanID + ')" />';
                }
            });
        }
    </script>
</head>
<base target="_self" />
<body>
<table class="tableEdit" id="tb1">
    <thead>
        <tr>
            <td>开发计划查看（<span style="color:blue">状态：开发中</span>）</td>
            <td style="text-align:right"><a href="#" onclick="$('.planTR').toggle();">新建</a>&nbsp;&nbsp;<a href="#" onclick="chengg()">开发成功</a>&nbsp;&nbsp;<a href="#" onclick="$('.shibaiTR').toggle();">开发终止</a></td>
        </tr>
    </thead>
    <tr class="shibaiTR" style="display:none;">
        <th>失败原因： <a href="#" onclick="shibai()">保存</a><br /></th>
        <td><textarea id="t3"></textarea></td>
    </tr>
    <tr class="planTR" style="display:none;">
        <th colspan="2">计划： <a href="#" onclick="baocun()">保存</a></th>
    </tr>
    <tr class="planTR" style="display:none;">
        <td colspan="2"><textarea id="t1"></textarea></td>
    </tr>
    <tr class="resultTR" style="display:none;">
        <th colspan="2">执行： <a href="#" onclick="baocun1()">保存</a></th>
    </tr>
    <tr class="resultTR" style="display:none;">
        <td colspan="2"><textarea id="t2">....</textarea></td>
    </tr>
    <!--<tr>
        <td>电话联系，初步接触</td>
        <td><input type="button" value="输入执行结果" onclick="$('.resultTR').toggle();" /></td>
    </tr>-->
    </table>
    <table class="tableEdit">
        <tr>
            <td colspan="2">
                <input type="button" value="关闭" onclick="window.close()" />
            </td>
        </tr>

    </table>
</body>
</html>

